package com.csweimei.rentmanagementtreasure.http;

import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;

import com.csweimei.rentmanagementtreasure.http.entity.AuthBean;
import com.csweimei.rentmanagementtreasure.http.entity.AutoBean;
import com.csweimei.rentmanagementtreasure.http.entity.BaseResult;
import com.csweimei.rentmanagementtreasure.http.entity.BindEntEntity;
import com.csweimei.rentmanagementtreasure.http.entity.BrokerCustomBean;
import com.csweimei.rentmanagementtreasure.http.entity.BrokerDailyBean;
import com.csweimei.rentmanagementtreasure.http.entity.BrokerFollowupBean;
import com.csweimei.rentmanagementtreasure.http.entity.BrokerHousingBean;
import com.csweimei.rentmanagementtreasure.http.entity.BrokerInfoBean;
import com.csweimei.rentmanagementtreasure.http.entity.CodeListBean;
import com.csweimei.rentmanagementtreasure.http.entity.CompanyBean;
import com.csweimei.rentmanagementtreasure.http.entity.CompanyInfoHomeBean;
import com.csweimei.rentmanagementtreasure.http.entity.CountBean;
import com.csweimei.rentmanagementtreasure.http.entity.CustomerBean;
import com.csweimei.rentmanagementtreasure.http.entity.CustomerCenterBean;
import com.csweimei.rentmanagementtreasure.http.entity.CustomerDetailBean;
import com.csweimei.rentmanagementtreasure.http.entity.CustomerFollowBean;
import com.csweimei.rentmanagementtreasure.http.entity.DailyListBean;
import com.csweimei.rentmanagementtreasure.http.entity.DealHouseListBean;
import com.csweimei.rentmanagementtreasure.http.entity.EntDealChatBean;
import com.csweimei.rentmanagementtreasure.http.entity.EntHomeDailyBean;
import com.csweimei.rentmanagementtreasure.http.entity.EntScheduleBean;
import com.csweimei.rentmanagementtreasure.http.entity.FollowListBean;
import com.csweimei.rentmanagementtreasure.http.entity.HouseDetailHzBean;
import com.csweimei.rentmanagementtreasure.http.entity.HouseDetailZzBean;
import com.csweimei.rentmanagementtreasure.http.entity.HouseFollowRecordBean;
import com.csweimei.rentmanagementtreasure.http.entity.HouseHistoryBean;
import com.csweimei.rentmanagementtreasure.http.entity.HouseInfoDetailBean;
import com.csweimei.rentmanagementtreasure.http.entity.HouseListBean;
import com.csweimei.rentmanagementtreasure.http.entity.HouseListEntBean;
import com.csweimei.rentmanagementtreasure.http.entity.JoinListBean;
import com.csweimei.rentmanagementtreasure.http.entity.LeaseDetailBean;
import com.csweimei.rentmanagementtreasure.http.entity.LeaseListBean;
import com.csweimei.rentmanagementtreasure.http.entity.LoginBean;
import com.csweimei.rentmanagementtreasure.http.entity.LookHouseBean;
import com.csweimei.rentmanagementtreasure.http.entity.MessageDetailBean;
import com.csweimei.rentmanagementtreasure.http.entity.MessageListBean;
import com.csweimei.rentmanagementtreasure.http.entity.NoticeMsgBean;
import com.csweimei.rentmanagementtreasure.http.entity.QuarterEntity;
import com.csweimei.rentmanagementtreasure.http.entity.SearchEntBean;
import com.csweimei.rentmanagementtreasure.http.entity.SearchStaffBean;
import com.csweimei.rentmanagementtreasure.http.entity.StaffListBean;
import com.csweimei.rentmanagementtreasure.http.entity.TabOne2Bean;
import com.csweimei.rentmanagementtreasure.http.entity.TabOneBean;
import com.csweimei.rentmanagementtreasure.http.entity.TabOneScheduleBean;
import com.csweimei.rentmanagementtreasure.http.entity.TabThreeBean;
import com.csweimei.rentmanagementtreasure.http.entity.TabTwoScheduleListBean;
import com.csweimei.rentmanagementtreasure.http.entity.UserInfoEntity;
import com.csweimei.rentmanagementtreasure.http.entity.VipBean;
import com.csweimei.rentmanagementtreasure.http.entity.WXBean;
import com.csweimei.rentmanagementtreasure.http.entity.WorkScheduleListBean;
import com.csweimei.rentmanagementtreasure.utils.uploadUtils.QiNiuYunBean;
import com.gtdev5.geetolsdk.mylibrary.beans.LoginInfoBean;
import java.util.Map;

import io.reactivex.Observable;
import me.goldze.mvvmhabit.base.BaseModel;
import me.goldze.mvvmhabit.utils.SPUtils;

/**
 * MVVM的Model层，统一模块的数据仓库，包含网络数据和本地数据（一个应用可以有多个Repositor）
 * Created by goldze on 2019/3/26.
 */
public class Repository extends BaseModel implements HttpDataSource, LocalDataSource {
    private volatile static Repository INSTANCE = null;
    private final HttpDataSource mHttpDataSource;

    private final LocalDataSource mLocalDataSource;

    private Repository(@NonNull HttpDataSource httpDataSource,
                       @NonNull LocalDataSource localDataSource) {
        this.mHttpDataSource = httpDataSource;
        this.mLocalDataSource = localDataSource;
    }

    public static Repository getInstance(HttpDataSource httpDataSource,
                                         LocalDataSource localDataSource) {
        if (INSTANCE == null) {
            synchronized (Repository.class) {
                if (INSTANCE == null) {
                    INSTANCE = new Repository(httpDataSource, localDataSource);
                }
            }
        }
        return INSTANCE;
    }

    @VisibleForTesting
    public static void destroyInstance() {
        INSTANCE = null;
    }

    @Override
    public void setLogin(LoginBean loginBean) {
        mLocalDataSource.setLogin(loginBean);
    }

    @Override
    public LoginBean getLoginInfo() {
        return mLocalDataSource.getLoginInfo();
    }

    @Override
    public boolean isLogin() {
        SPUtils.getInstance().put("login",mLocalDataSource.isLogin());
        return mLocalDataSource.isLogin();
    }

    @Override
    public void setUserInfo(UserInfoEntity userInfo) {
        mLocalDataSource.setUserInfo(userInfo);
    }

    @Override
    public UserInfoEntity getUserInfo() {
        return mLocalDataSource.getUserInfo();
    }


    @Override
    public Observable<LoginBean> qq_login(Map<String, String> map) {
        return mHttpDataSource.qq_login(map);
    }

    @Override
    public Observable<LoginBean> wechet_login(Map<String, String> map) {
        return mHttpDataSource.wechet_login(map);
    }

    @Override
    public Observable<BaseResult> edituserinfo(Map<String, String> map) {
        return mHttpDataSource.edituserinfo(map);
    }

    @Override
    public Observable<UserInfoEntity> userinfo(Map<String, String> map) {
        return mHttpDataSource.userinfo(map);
    }

    @Override
    public Observable<AuthBean> seachauth(Map<String, String> map) {
        return mHttpDataSource.seachauth(map);
    }

    @Override
    public Observable<BindEntEntity> isbindEnt(Map<String, String> map) {
        return mHttpDataSource.isbindEnt(map);
    }

    @Override
    public Observable<BaseResult> logoff(Map<String, String> map) {
        return mHttpDataSource.logoff(map);
    }

    @Override
    public Observable<QuarterEntity> get_quarters(Map<String, String> map) {
        return mHttpDataSource.get_quarters(map);
    }

    @Override
    public Observable<BaseResult> add_quarters(Map<String, String> map) {
        return mHttpDataSource.add_quarters(map);
    }

    @Override
    public Observable<QiNiuYunBean> getToken() {
        return mHttpDataSource.getToken();
    }

    @Override
    public Observable<BaseResult> addwhole(Map<String, String> map) {
        return mHttpDataSource.addwhole(map);
    }

    @Override
    public Observable<HouseInfoDetailBean> wholeinfo(Map<String, String> map) {
        return mHttpDataSource.wholeinfo(map);
    }

    @Override
    public Observable<HouseDetailHzBean> cotenancyinfo(Map<String, String> map) {
        return mHttpDataSource.cotenancyinfo(map);
    }

    @Override
    public Observable<HouseListBean> housinglist(Map<String, String> map) {
        return mHttpDataSource.housinglist(map);
    }

    @Override
    public Observable<BaseResult> housingstatic(Map<String, String> map) {
        return mHttpDataSource.housingstatic(map);
    }

    @Override
    public Observable<BaseResult> delete_housing(Map<String, String> map) {
        return mHttpDataSource.delete_housing(map);
    }

    @Override
    public Observable<BaseResult> edit_housing(Map<String, String> map) {
        return mHttpDataSource.edit_housing(map);
    }

    @Override
    public Observable<HouseFollowRecordBean> follow_housing(Map<String, String> map) {
        return mHttpDataSource.follow_housing(map);
    }

    @Override
    public Observable<CustomerFollowBean> followdetails(Map<String, String> map) {
        return mHttpDataSource.followdetails(map);
    }

    @Override
    public Observable<FollowListBean> followup(Map<String, String> map) {
        return mHttpDataSource.followup(map);
    }

    @Override
    public Observable<BaseResult> addfollow(Map<String, String> map) {
        return mHttpDataSource.addfollow(map);
    }

    @Override
    public Observable<LeaseListBean> leaselist(Map<String, String> map) {
        return mHttpDataSource.leaselist(map);
    }

    @Override
    public Observable<BaseResult> deletelease(Map<String, String> map) {
        return mHttpDataSource.deletelease(map);
    }

    @Override
    public Observable<BaseResult> addlease(Map<String, String> map) {
        return mHttpDataSource.addlease(map);
    }

    @Override
    public Observable<HouseHistoryBean> history_leaselist(Map<String, String> map) {
        return mHttpDataSource.history_leaselist(map);
    }

    @Override
    public Observable<LeaseDetailBean> lease_detail(Map<String, String> map) {
        return mHttpDataSource.lease_detail(map);
    }

    @Override
    public Observable<BaseResult> addcustom(Map<String, String> map) {
        return mHttpDataSource.addcustom(map);
    }

    @Override
    public Observable<BaseResult> deletecustom(Map<String, String> map) {
        return mHttpDataSource.deletecustom(map);
    }

    @Override
    public Observable<CustomerBean> seachcustom(Map<String, String> map) {
        return mHttpDataSource.seachcustom(map);
    }

    @Override
    public Observable<CustomerDetailBean> customdetails(Map<String, String> map) {
        return mHttpDataSource.customdetails(map);
    }

    @Override
    public Observable<LookHouseBean> showingslist(Map<String, String> map) {
        return mHttpDataSource.showingslist(map);
    }

    @Override
    public Observable<AutoBean> mateinfo(Map<String, String> map) {
        return mHttpDataSource.mateinfo(map);
    }

    @Override
    public Observable<HouseDetailZzBean> allhouser_data(Map<String, String> map) {
        return mHttpDataSource.allhouser_data(map);
    }

    @Override
    public Observable<BaseResult> addcotenancy(Map<String, String> map) {
        return mHttpDataSource.addcotenancy(map);
    }

    @Override
    public Observable<TabOneBean> beleaselist(Map<String, String> map) {
        return mHttpDataSource.beleaselist(map);
    }

    @Override
    public Observable<NoticeMsgBean> copywriting(Map<String, String> map) {
        return mHttpDataSource.copywriting(map);
    }

    @Override
    public Observable<TabOne2Bean> homerecords(Map<String, String> map) {
        return mHttpDataSource.homerecords(map);
    }

    @Override
    public Observable<TabOneScheduleBean> myschedule(Map<String, String> map) {
        return mHttpDataSource.myschedule(map);
    }

    @Override
    public Observable<BaseResult> addschedule(Map<String, String> map) {
        return mHttpDataSource.addschedule(map);
    }

    @Override
    public Observable<TabTwoScheduleListBean> schedulelist(Map<String, String> map) {
        return mHttpDataSource.schedulelist(map);
    }

    @Override
    public Observable<TabThreeBean> message_center(Map<String, String> map) {
        return mHttpDataSource.message_center(map);
    }

    @Override
    public Observable<MessageDetailBean> messageinfo(Map<String, String> map) {
        return mHttpDataSource.messageinfo(map);
    }

    @Override
    public Observable<MessageListBean> messagelist(Map<String, String> map) {
        return mHttpDataSource.messagelist(map);
    }

    @Override
    public Observable<BaseResult> edit_message(Map<String, String> map) {
        return mHttpDataSource.edit_message(map);
    }

    @Override
    public Observable<SearchEntBean> seachcompany(Map<String, String> map) {
        return mHttpDataSource.seachcompany(map);
    }

    @Override
    public Observable<DailyListBean> dailylist(Map<String, String> map) {
        return mHttpDataSource.dailylist(map);
    }

    @Override
    public Observable<BaseResult> adddaily(Map<String, String> map) {
        return mHttpDataSource.adddaily(map);
    }

    @Override
    public Observable<BaseResult> addbroker(Map<String, String> map) {
        return mHttpDataSource.addbroker(map);
    }

    @Override
    public Observable<BaseResult> dailydetails(Map<String, String> map) {
        return mHttpDataSource.dailydetails(map);
    }

    @Override
    public Observable<BaseResult> exit_company(Map<String, String> map) {
        return mHttpDataSource.exit_company(map);
    }

    @Override
    public Observable<CompanyBean> getcompany_info(Map<String, String> map) {
        return mHttpDataSource.getcompany_info(map);
    }

    @Override
    public Observable<BaseResult> companyinfo(Map<String, String> map) {
        return mHttpDataSource.companyinfo(map);
    }

    @Override
    public Observable<BaseResult> addcompanyauth(Map<String, String> map) {
        return mHttpDataSource.addcompanyauth(map);
    }

    @Override
    public Observable<EntDealChatBean> dealchat(Map<String, String> map) {
        return mHttpDataSource.dealchat(map);
    }

    @Override
    public Observable<EntHomeDailyBean> companydaily(Map<String, String> map) {
        return mHttpDataSource.companydaily(map);
    }

    @Override
    public Observable<EntScheduleBean> allschedule(Map<String, String> map) {
        return mHttpDataSource.allschedule(map);
    }

    @Override
    public Observable<BaseResult> companyseek(Map<String, String> map) {
        return mHttpDataSource.companyseek(map);
    }

    @Override
    public Observable<HouseListEntBean> allhousing(Map<String, String> map) {
        return mHttpDataSource.allhousing(map);
    }

    @Override
    public Observable<CustomerCenterBean> customcenter(Map<String, String> map) {
        return mHttpDataSource.customcenter(map);
    }

    @Override
    public Observable<DealHouseListBean> deallist(Map<String, String> map) {
        return mHttpDataSource.deallist(map);
    }

    @Override
    public Observable<WorkScheduleListBean> workschedule(Map<String, String> map) {
        return mHttpDataSource.workschedule(map);
    }

    @Override
    public Observable<BaseResult> handle(Map<String, String> map) {
        return mHttpDataSource.handle(map);
    }

    @Override
    public Observable<JoinListBean> joincompanylist(Map<String, String> map) {
        return mHttpDataSource.joincompanylist(map);
    }

    @Override
    public Observable<CompanyInfoHomeBean> myinfo(Map<String, String> map) {
        return mHttpDataSource.myinfo(map);
    }

    @Override
    public Observable<BaseResult> allhouser_data_ent(Map<String, String> map) {
        return mHttpDataSource.allhouser_data_ent(map);
    }

    @Override
    public Observable<StaffListBean> stafflist(Map<String, String> map) {
        return mHttpDataSource.stafflist(map);
    }

    @Override
    public Observable<BrokerFollowupBean> brokerfollowup(Map<String, String> map) {
        return mHttpDataSource.brokerfollowup(map);
    }

    @Override
    public Observable<BrokerDailyBean> brokerdaily(Map<String, String> map) {
        return mHttpDataSource.brokerdaily(map);
    }

    @Override
    public Observable<BrokerCustomBean> brokercustom(Map<String, String> map) {
        return mHttpDataSource.brokercustom(map);
    }

    @Override
    public Observable<BrokerInfoBean> brokeruser(Map<String, String> map) {
        return mHttpDataSource.brokeruser(map);
    }

    @Override
    public Observable<BrokerHousingBean> brokerhousingdata(Map<String, String> map) {
        return mHttpDataSource.brokerhousingdata(map);
    }

    @Override
    public Observable<BaseResult> deletebroker(Map<String, String> map) {
        return mHttpDataSource.deletebroker(map);
    }

    @Override
    public Observable<BaseResult> invitebroker(Map<String, String> map) {
        return mHttpDataSource.invitebroker(map);
    }

    @Override
    public Observable<SearchStaffBean> seachbroker(Map<String, String> map) {
        return mHttpDataSource.seachbroker(map);
    }

    @Override
    public Observable<VipBean> seach_vip(Map<String, String> map) {
        return mHttpDataSource.seach_vip(map);
    }

    @Override
    public Observable<CodeListBean> mycode(Map<String, String> map) {
        return mHttpDataSource.mycode(map);
    }

    @Override
    public Observable<BaseResult> usecode(Map<String, String> map) {
        return mHttpDataSource.usecode(map);
    }

    @Override
    public Observable<BaseResult> delete_code(Map<String, String> map) {
        return mHttpDataSource.delete_code(map);
    }

    @Override
    public Observable<BaseResult> deliver_code(Map<String, String> map) {
        return mHttpDataSource.deliver_code(map);
    }

    @Override
    public Observable<WXBean> WeChetPay(Map<String, String> map) {
        return mHttpDataSource.WeChetPay(map);
    }

    @Override
    public Observable<CountBean> housing_item(Map<String, String> map) {
        return mHttpDataSource.housing_item(map);
    }
}
